package com.dangdang.action.order;

import java.io.UnsupportedEncodingException;

import com.dangdang.action.BaseAction;
import com.dangdang.domain.ReceiveAddress;
import com.dangdang.service.CartService;
import com.dangdang.service.OrderService;
import com.dangdang.service.ServiceFactory;

/**
 * 生成订单
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-1-30
 */
public class CreateOrderAction extends BaseAction {

	private ReceiveAddress address;

	public ReceiveAddress getAddress() {
		return address;
	}

	public void setAddress(ReceiveAddress address) {
		this.address = address;
	}

	private OrderService os = ServiceFactory.getOrderService();
	private CartService cs;

	public String execute() throws UnsupportedEncodingException {
		cs = ServiceFactory.getCartService(session);
		os.createOrder(cs, address);
		cs.clear();
		return "success";
	}
}
